<template>
    <div>
        <!-- 共用头部组件 -->
        <common-header
            :headerTitle="'明星店主 — '+starList[this.$route.query.starId].starName"
            :hasBack="true"
            :hasHome="true"
        ></common-header>
        <!-- 共用头部组件 -->

        <!-- 共用页面滚动组件 -->
        <common-scroll
            :scrollStyle="scrollStyle"
            :isLoadMore="false"
        >

            <div class="star-detail">
                <img
                    class="star-img"
                    v-lazy="item"
                    v-for="(item,index) of starList[this.$route.query.starId].starImgList"
                    :key="index"
                />
            </div>

        </common-scroll>
        <!-- 共用页面滚动组件 -->
    </div>
</template>

<script>
import CommonHeader from '@/components/Header'
import CommonScroll from '@/components/Scroll'
import wx from 'weixin-js-sdk'
export default {
    name: 'StarDetail',
    components: {
        CommonHeader,
        CommonScroll
    },
    data() {
        return {
            scrollStyle: {
                top: '1.11rem',
                left: '0',
                right: '0',
                bottom: '0',
                background: '#fff'
            },
            starList: [
                {
                    starName: '钟林丽',
                    starDetail: '最耀眼的是——你努力奋斗的样子。',
                    starImgList: [
                        require('@/assets/images/star/star-img-3-1.jpg'),
                        require('@/assets/images/star/star-img-3-2.jpg'),
                        require('@/assets/images/star/star-img-3-3.jpg'),
                        require('@/assets/images/star/star-img-3-4.jpg')
                    ]
                },
                {
                    starName: '马年凤',
                    starDetail: '马年凤是多面体，别样人生也有千种美丽。',
                    starImgList: [
                        require('@/assets/images/star/star-img-2-1.jpg'),
                        require('@/assets/images/star/star-img-2-2.jpg'),
                        require('@/assets/images/star/star-img-2-3.jpg'),
                        require('@/assets/images/star/star-img-2-4.jpg'),
                        require('@/assets/images/star/star-img-2-5.jpg'),
                        require('@/assets/images/star/star-img-2-6.jpg'),
                        require('@/assets/images/star/star-img-2-7.jpg')
                    ]
                },
                {
                    starName: '钟鑫',
                    starDetail:
                        '她叫钟鑫，拥有双重魅力的优雅女性。她因为爱美而年收入几十万，你爱美吗？',
                    starImgList: [
                        require('@/assets/images/star/star-img-1-1.jpg'),
                        require('@/assets/images/star/star-img-1-2.jpg'),
                        require('@/assets/images/star/star-img-1-3.jpg'),
                        require('@/assets/images/star/star-img-1-4.jpg'),
                        require('@/assets/images/star/star-img-1-5.jpg'),
                        require('@/assets/images/star/star-img-1-6.jpg')
                    ]
                }
            ]
        }
    },
    mounted() {
        this.getWxConfig()
    },
    methods: {
        getWxConfig() {
            const that = this
            this.axios.post('/api/jsconfig.json').then(res => {
                const data = res.data
                if (data.status == 1) {
                    let routeHost = window.location.origin
                    let routeHref = window.location.href.split('#')[0]
                    let routePath = encodeURIComponent(
                        window.location.href.split('#')[1]
                    )
                    wx.config(data.data)
                    wx.ready(function() {
                        if (typeof wx.updateAppMessageShareData == 'function') {
                            wx.updateAppMessageShareData({
                                title:
                                    '百领好货明星店主：' +
                                    that.starList[that.$route.query.starId]
                                        .starName, // 分享标题
                                desc:
                                    that.starList[that.$route.query.starId]
                                        .starDetail, // 分享描述
                                link: routeHref + '&route=' + routePath, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl: routeHost + '/static/images/logo.png', // 分享图标
                                success: function() {
                                    // 设置成功
                                }
                            })
                        } else {
                            wx.onMenuShareAppMessage({
                                title:
                                    '百领好货明星店主：' +
                                    that.starList[that.$route.query.starId]
                                        .starName, // 分享标题
                                desc:
                                    that.starList[that.$route.query.starId]
                                        .starDetail, // 分享描述
                                link: routeHref + '&route=' + routePath, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl: routeHost + '/static/images/logo.png', // 分享图标
                                type: '', // 分享类型,music、video或link，不填默认为link
                                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                                success: function() {
                                    // 用户点击了分享后执行的回调函数
                                }
                            })
                        }
                        if (typeof wx.onMenuShareTimeline == 'function') {
                            wx.onMenuShareTimeline({
                                title:
                                    '百领好货明星店主：' +
                                    that.starList[that.$route.query.starId]
                                        .starName, // 分享标题
                                desc:
                                    that.starList[that.$route.query.starId]
                                        .starDetail, // 分享描述
                                link: routeHref + '&route=' + routePath, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl: routeHost + '/static/images/logo.png', // 分享图标
                                success: function() {
                                    // 设置成功
                                }
                            })
                        } else {
                            wx.onMenuShareTimeline({
                                title:
                                    '百领好货明星店主：' +
                                    that.starList[that.$route.query.starId]
                                        .starName, // 分享标题
                                desc:
                                    that.starList[that.$route.query.starId]
                                        .starDetail, // 分享描述
                                link: routeHref + '&route=' + routePath, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                                imgUrl: routeHost + '/static/images/logo.png', // 分享图标
                                success: function() {
                                    // 用户点击了分享后执行的回调函数
                                }
                            })
                        }
                    })
                } else {
                    this.commonDialog.alert('提示', data.msg)
                }
            })
        }
    }
}
</script>

<style lang="stylus" scoped>
.star-detail
    .star-img
        width 100%
</style>
